package com.mdd.common.entity.zdjd.param;

import com.mdd.common.entity.zdjd.TZdjdDeviceStateRecord;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;

@Data
@ApiModel("设备运行状态入参")
public class DeviceRunStatusParam implements Serializable {

    @ApiModelProperty(value = "回传数据设备唯一id")
    private String id;

    @ApiModelProperty(value = "设备编码/设备型号")
    private String model;

    @ApiModelProperty(value = "设备状态（0:待机 1:运行 2:故障停机 3:保温）")
    private Integer stat;

    @ApiModelProperty(value = "报警类型编码")
    private String aCode;

    @ApiModelProperty(value = "时间戳（精确到秒的采集时间）")
    private String ts;

    @ApiModelProperty(value = "GPS经度")
    private Double lon;

    @ApiModelProperty(value = "GPS纬度")
    private Double lat;

    @ApiModelProperty(value = "瞬时油耗（单位mL/min）")
    private Double ifc;

    @ApiModelProperty(value = "本次油耗（单位mL）")
    private Double cfc;

    @ApiModelProperty(value = "累计油耗（单位L）")
    private Double tfc;

    @ApiModelProperty(value = "本次运行时间（单位min）")
    private Double rt;

    @ApiModelProperty(value = "累计运行时间（单位h）")
    private Double art;




    public static TZdjdDeviceStateRecord cover(DeviceRunStatusParam param,Long deviceId) {
        Date now = new Date();
        Calendar calendar = Calendar.getInstance();
        TZdjdDeviceStateRecord record = new TZdjdDeviceStateRecord();
        record.setDeviceUuid(param.getId());
        record.setDeviceId(deviceId);
        record.setDeviceCode(param.getModel());
        record.setStatus(param.getStat());
        record.setAlarmCode(param.getACode());
        record.setTimeStamp(param.getTs());
        record.setLongitude(param.getLon());
        record.setLatitude(param.getLat());
        record.setCreateTime(now);
        record.setUpdateTime(now);
        record.setYear(String.valueOf(calendar.get(Calendar.YEAR)));
        record.setMonth(String.valueOf(calendar.get(Calendar.MONTH)+1));
        record.setDay(String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
        return record;
    }

}
